package com.gxa.modules.sys.controller;

import com.gxa.common.utils.Result;
import com.gxa.modules.sys.entity.Area;
import com.gxa.modules.sys.service.AreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api(tags = "区域管理接口")
@RestController
public class AreaController {

   @Autowired
private AreaService areaService;

    @ApiOperation(value = "点击区域管理，获取区域数据")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "id",value ="查询条件",dataType ="int"),
    })
    @GetMapping("/area/queryall")
    public
    Result queryAll(@RequestParam @ApiIgnore Map<String, Object> params) {



    try{
//        this.codeService.addCode(cdkeyDto,cdkeyList);
        List<Area> areas = areaService.queryAll(params);
        return new Result().ok(areas);
    } catch (Exception e) {
        e.printStackTrace();
        return new Result().error("查询数据失败");



    }
    }



    @ApiOperation(value = "点击确认修改，修改区域数据")
    @PutMapping("/area/updateArea")
    public
    Result updateArea(@RequestBody Area area) {


//        this.codeService.addCode(cdkeyDto,cdkeyList);

      try{  areaService.updateArea(area);
        return new Result().ok();
    } catch (Exception e) {
        e.printStackTrace();
        return new Result().error("查询数据失败");



    }

    }

    
}
